package com.zyp.staticProxy;


/**
 * 
 * 代理类
 * 
 * 代理类与目标类实现同一个接口Subject
 * 
 */
public class Proxy implements Subject{

	
	//代理类中存在一个被代理的对象
	private Subject delegate;
	
	//在无参构造器中直接创建被代理的对象
	public Proxy(){
		if(delegate==null){
			this.delegate=new RealSubject();
		}
	}

	@Override
	public void doSomething() {
		System.out.println("proxy dosomething  before");
		delegate.doSomething();
		System.out.println("proxy dosomething  after");
	}
	
	
}
